home *** CD-ROM | disk | FTP | other *** search
/ Disc to the Future 2 / Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin / MAC / THINKC / 4_0 / MUBBS_MO / EXAMPLE2 / EXAMPLE2.C < prev    next >
Text File  |  1991-11-21  |  2KB  |  59 lines

  1. /*
  2.  *  test module main.c
  3.  *
  4.  *    This program source code and it's compiled version is
  5.  *  Copyright (c) 1991 N. Hawthorn.
  6.  *  This program source code and it's compiled version IS NOT IN THE
  7.  *  PUBLIC DOMAIN ! Please read the "COPYRIGHT NOTICE / NH" file for details
  8.  *  regarding use of this program source code and it's compiled version.
  9.  *
  10.  *  This module's name is "Example2", it's type is "MOD1", it's ID is 130
  11.  *  because we know the menu module's ID is 128. Normally a resource mover
  12.  *  would assign a new number to it, that's why we name our modules !
  13.  *
  14.  * This is where it all starts...
  15.  *
  16.  */
  17.  
  18. #define INMAIN
  19.  
  20. #include <SetUpA4.h>
  21. #include "MUBBS Module.h"
  22.  
  23.  
  24. pascal void main (mode1,G1,P1) /* called from the main routines, and what mode to be in */
  25. int mode1;
  26. struct GS *G1; /* we point to the "global" struct in the Main Module here */
  27. Ptr P1;
  28. {
  29. Handle temph;
  30. float version = 0.5; /* what version of MUBBS you are compatable with IE: .5 and above */
  31. RememberA0(); SetUpA4(); /* This sets up the A4 register to access our globals */
  32. asm { _RecoverHandle }; asm {move.l a0,temph}; HLock(temph); /* locks our module, do this ! */
  33.  
  34. G=G1; /* This MUST be the first thing you do in main only, it sets up our globals */
  35. mode[u]=mode1; /* set up our mode so that you can read it anywhere */
  36.  
  37. switch (mode[u]) { /* any un-handled modes return error from this module */
  38.     case 2:
  39.     case 3:
  40.         tests(P1); /* we actually handle both calls by looking at pointer NIL */
  41.         G->moduleresult=0;
  42.         break;
  43.     case 98:
  44.         versionck(version); /* just return after this call, don't modify anything */
  45.         break;        
  46.     case 0:
  47.         strcpy (G->programmer,"N Hawthorn"); /* show the programmer's name up to 20 chars*/
  48.         G->moduleresult=0; /* this was also a init call if we need close call put 99 here */
  49.         break;
  50.     default:
  51.         G->moduleresult=1; /* return bad code */
  52.     };
  53.  
  54. HUnlock(temph); /* unlocks this module, do this ! */
  55. RestoreA4(); /* call this when you are all done */
  56. }
  57.  
  58.  
  59.